<html>
<head><meta charset="utf-8"><title>Use mir for while_let_on_iterator · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Use.20mir.20for.20while_let_on_iterator.html">Use mir for while_let_on_iterator</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216486601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Use%20mir%20for%20while_let_on_iterator/near/216486601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Cameron Steffen <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Use.20mir.20for.20while_let_on_iterator.html#216486601">(Nov 12 2020 at 15:53)</a>:</h4>
<p>Am I right in thinking that <a href="https://github.com/rust-lang/rust-clippy/issues/5844">#5844</a> is a good case for mir analysis? To summarize, I need to know if I can transform <code>while let Some(_) = iter.next()</code> into <code>for _ in iter</code> without causing a borrow-after-move error. So, can I use mir to see if <code>iter</code> is borrowed after the while let loop? I've been trolling the rustc API docs and I see a lot of things that look vaguely useful, mostly in the dataflow mod, but I don't know where to go from here.</p>



<a name="216488469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Use%20mir%20for%20while_let_on_iterator/near/216488469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Use.20mir.20for.20while_let_on_iterator.html#216488469">(Nov 12 2020 at 16:04)</a>:</h4>
<p><span class="user-mention" data-user-id="281841">@Robin Moussu</span> recently worked with MIR, maybe they have ideas</p>



<a name="216488892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Use%20mir%20for%20while_let_on_iterator/near/216488892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Use.20mir.20for.20while_let_on_iterator.html#216488892">(Nov 12 2020 at 16:07)</a>:</h4>
<p>I also think that MIR is the right place to do that analysis, but I'm not yet experienced enough to be able to advice you on how to do it <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>